﻿using System.Collections.ObjectModel;
using Bridge.Base.Constructs;

namespace Pathfinder.Base.Constructs
{
    public class HitDice : ChangableObject
    {
        public int DiceNumber
        {
            get { return mDiceNumber; }
            set { CheckPropertyChanged<int>("DiceNumber", ref mDiceNumber, ref value); }
        }

        public int DiceSize
        {
            get { return mDiceSize; }
            set
            {
                CheckPropertyChanged<int>("DiceSize", ref mDiceSize, ref value);
                int oldDiceFace = DiceFace;
                DiceChoices.Clear();
                for (int i = 1; i <= mDiceSize; i++)
                {
                    DiceChoices.Add(i);
                }
                if (oldDiceFace <= mDiceSize)
                {
                    DiceFace = oldDiceFace;
                }
                else
                {
                    DiceFace = 1;
                }
            }
        }

        public int DiceFace
        {
            get { return mDiceFace; }
            set { CheckPropertyChanged<int>("DiceFace", ref mDiceFace, ref value); }
        }

        public ObservableCollection<int> DiceSizes
        {
            get { return mDiceSizes; }
            set { CheckPropertyChanged<ObservableCollection<int>>("DiceSizes", ref mDiceSizes, ref value); }
        }

        public ObservableCollection<int> DiceChoices
        {
            get { return mDiceChoices; }
            set { CheckPropertyChanged<ObservableCollection<int>>("DiceChoices", ref mDiceChoices, ref value); }
        }


        private int mDiceNumber = 0;
        private int mDiceSize = 0;
        private int mDiceFace = 1;
        private ObservableCollection<int> mDiceSizes = new ObservableCollection<int>() { 6, 8, 10, 12 };
        private ObservableCollection<int> mDiceChoices = new ObservableCollection<int>();
    }
}
